<form id="s_cz_div" class="layui-form">
    <div id='layers' class="layui-form-item">
        <label class="layui-form-label">选择图层</label>
        <div class="layui-input-block"></div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" style="text-align: right;">
            <button id="tj" type="button" class="layui-btn layui-btn-normal">统&nbsp;&nbsp;计</button>
            <button type="reset" class="layui-btn layui-btn-primary">重&nbsp;&nbsp;置</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    let lyrs = CONST_VALUES.GX_Datas;
    //debugger;
    let checkboxStr = "<input type='checkbox' name='THENAME' title='THETITLE' id='THEID' lay-skin='primary' dataSetName='THEDATASETNAME' dataSourceName='THEWS'>";
    for (let index = 0; index < lyrs.length; index++) {
        const lyr = lyrs[index];
        //debugger;
        if (lyr.name.indexOf("管线") < 0)
            continue;
        var dom = checkboxStr.replace('THENAME', lyr.name);
        dom = dom.replace('THETITLE', lyr.name);
        dom = dom.replace('THEID', lyr.id);
        dom = dom.replace('THEWS', lyr.dataSourceName);
        dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
        //debugger;
        $("#layers .layui-input-block").append(dom);
    }

    $("#s_cz_div #tj").click(function(obj) {
        var layers = $("#layers input:checked");
        if (layers.length == 0) {
            layer.msg('请至少选择一个图层！', {
                icon: 7
            });
            return;
        }
        let selectLayers = "";
        let xAxis = [];
        for (let index = 0; index < layers.length; index++) {
            let checked = layers[index].checked;
            if (!checked)
                continue;
            selectLayers += mapDatas.getLayerNameByCaption(layers[index].name) + ","
            xAxis.push(layers[index].name);
        }
        $.ajax({
            url: "statistics/spatialstatistics?tbNames=" + selectLayers,
            success: function(result) {
                panels.createResultPanelWithChart(xAxis, /**/
                    result, "按管径统计", "单位：米", "管径", "长度", "bar",
                    function() {
                        //debugger;
                    });
            },
            error: function() {
                layer.msg('统计报错！', {
                    icon: 7
                });
            }
        });
    });
</script>